package com.yixing.demo.config;

import com.yixing.demo.component.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    List<String> excludePath = Arrays.asList(
            "/dist/**",
            "/static1/**",
            "/vendor/**",
            "/login.html",
            "/register.html",
            "/index.html",
            "/**/uploadavatar.html",
            "/user/login",
            "/user/register"
    );

    @Resource
    LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(excludePath);
    }
}
